package com.warmlight.voicepacket;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.view.View;

import com.warmlight.voicepacket.base.BaseActivity;
import com.warmlight.voicepacket.data.TopicTabData;
import com.warmlight.voicepacket.widget.CoverLoading;

import java.util.List;

/**
 * Created by jason on 2018/5/23.
 */

public class RecommendPlaylistActivity extends BaseActivity {

    private CoverLoading cover_status;
    private TabLayout tl_playlist_topic;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recommend_playlist);

        initView();

        getServerData();
        //TODO 直接获取
    }

    private void initView(){
        cover_status = (CoverLoading) findViewById(R.id.cover_status);
        cover_status.setResult(CoverLoading.LoadingResult.LOADING);
        tl_playlist_topic = (TabLayout) findViewById(R.id.tl_playlist_topic);
        fillTopic(tl_playlist_topic,null);

        //TODO list数据准备
    }


    private void getServerData(){
        //TODO 模拟假数据
//        List<>
    }

    private void fillTopic(TabLayout tl, List<TopicTabData> list) {
        if(tl != null){
            tl.setVisibility(View.GONE);
        }
        if(tl == null || list == null || list.size() == 0){
            return;
        }
        for (TopicTabData temp : list) {
            tl.addTab(tl.newTab().setText(temp.getName()));
        }
        tl.setVisibility(View.VISIBLE);
    }
}
